package edu.ynmd.class1.action;

import edu.ynmd.class1.dao.StudentDao;
import edu.ynmd.class1.model.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.Timestamp;

@Controller
public class PublicAtion {


    @Autowired
    private StudentDao studentDao;


    @GetMapping("testDao")
    @ResponseBody
    public boolean testDao() throws Exception{
        //添加
//        Student student = new Student();
//        student.setStunum("201621447136");
//        student.setName("姓名");
//        student.setSex("F");
//        student.setBirthday(new Timestamp(System.currentTimeMillis()));
//        student.setNativeplace("云南玉溪");
//        studentDao.save(student);


        //修改
//        Student student = new Student();
//        student.setStudentid("c74a1a83-eb16-477b-9881-6c0cb4d8c7de");
//        student.setStunum("201621447102");
//        student.setName("姓名修改");
//        studentDao.save(student);


        //查询
//        Student student = studentDao.findOne("c74a1a83-eb16-477b-9881-6c0cb4d8c7de");
//        student.setSex("M");
//        student.setBirthday(new Timestamp(System.currentTimeMillis()));
//        student.setNativeplace("红塔区");
//        studentDao.save(student);


        //删除
          Student student = new Student();
          student.setStudentid("c74a1a83-eb16-477b-9881-6c0cb4d8c7de");
          studentDao.delete(student);
        return true;

    }
}
